package umich.max.geolocation.experiments;

import java.util.ArrayList;
import java.util.List;

import max.nlp.util.basic.TimeUtils;
import max.nlp.wrappers.ml.weka.NClassClassifier;
import max.nlp.wrappers.ml.weka.WekaFeatureBuilder;

@SuppressWarnings("rawtypes")
public class ClassifyNStates extends BlogExperiment {
 

	@SuppressWarnings("serial")
	public static void main(String[] args) {
		ClassifyNStates cs2 = new ClassifyNStates();

		List<String> classes = new ArrayList<String>() {
			{
				add("NY");
				add("CA");
			}
		};

		List<String> extractors = new ArrayList<String>() {
			{
				add("tf");
//				add("bLoc");
//				add("mpLoc");
//				add("perLoc");
			}
		};
		
		String fb = "blog3";
		cs2.buildClassifier(fb, extractors, classes);

	}

	public void buildClassifier(String fb, List<String> extractors, List<String> classes) {

		long start = System.currentTimeMillis();

		// Setup experiment directory
		String dirName = "";
		for (int i = 0; i < classes.size(); i++) {
			String c = classes.get(i);
			if (!(i + 1 < classes.size()))
				dirName += c;
			else
				dirName += c + "-";
		}

		String fullDir = "/home/max/workspace/geolocation/experiments/misc/"
				+ dirName + "/";
		setupDirectory(fullDir);
		System.out.println(fullDir);
		// get feature extractors
		WekaFeatureBuilder bfb = getFeatureBuilder(fb,extractors);

		// Make and configure classifier
		NClassClassifier c = new NClassClassifier(classes, bfb);

		c.setExperimentDir(fullDir);
		c.shouldUseSaved(false);
		c.shouldSaveResults(true);
		c.shouldBalanceClasses(true);
		c.evaluateWithCrossFoldValidation();

		c.run();

		// Finish
		long end = System.currentTimeMillis();
		long duration = (end - start);
		System.out.println("Duration : "
				+ TimeUtils.getDurationBreakdown(duration));

	}

}
